package com.wink.subscribe;

import com.mongodb.MongoException;
import com.storage.mongo.Echarity;
import java.net.UnknownHostException;
import java.util.List;
import java.util.TimerTask;

public class SubscribeEmailTask extends TimerTask{
	
	private SubscriptionList sl;
	
	//constructor
	public SubscribeEmailTask() throws UnknownHostException, MongoException {
		sl = new SubscriptionList();
	}
	
	@Override
	public void run() {
		List<MongoSub> subList = sl.getAllSubs();
		
		for(MongoSub x: subList) {
			List<Echarity> charityList = sl.getCharitiesGivenSub(x);
			System.out.println("Email: " + x.getEmail());
			for(Echarity c: charityList) {
				System.out.println(c.getCharityName());
			}
		}
	}
}
